package com.wjc.myktapplication.page.wxaccount

import androidx.lifecycle.MutableLiveData
import com.wjc.basemodule.utils.LogTools
import com.wjc.myktapplication.data.NetworkManager
import com.wjc.myktapplication.data.wxaccount.WxAccountBean
import com.wjc.network.ResponseResult
import com.wjc.network.RetrofitFactory
import io.reactivex.rxjava3.core.SingleObserver
import io.reactivex.rxjava3.disposables.Disposable

/**
 * ClassName: com.wjc.myktapplication.page.wxaccount
 * Description:
 * JcChen on 2021.04.18.15:02
 */
class AccountReq {
    val TAG = "AccountReq"
    fun wxAccountList(result: MutableLiveData<ResponseResult<MutableList<WxAccountBean>>>) {
        NetworkManager.fetchApiService().fetchWxArticleList()
            .compose(RetrofitFactory.applySchedulers(object :
                        SingleObserver<ResponseResult<MutableList<WxAccountBean>>> {
                        override fun onSubscribe(d: Disposable?) {

                        }

                        override fun onSuccess(t: ResponseResult<MutableList<WxAccountBean>>?) {
                            LogTools.d(TAG, ": t=$t");
                            result.value = t
                        }

                        override fun onError(e: Throwable?) {
                            result.value = null
                        }
                    }
            ))
    }



}